﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Dzzzr.DataLayer;

namespace Dzzzr
{
  public partial class EntityType
  {
    [DataObjectMethod(DataObjectMethodType.Select,true)]
    public static List<EntityType> GetEntityTypes()
    {
      List<EntityType> entityTypes = new List<EntityType>();
      using (SqlConnection cnn = Helper.Connection)
      {
        SqlCommand cmd = new SqlCommand("GetEntityTypes", cnn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataReader rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        while (rd.Read())
        {
          EntityType entityType = new EntityType();
          entityType.ID = rd.GetInt32(0);
          entityType.Name = rd.GetString(1);
          entityTypes.Add(entityType);
        }
      }
      return entityTypes;
    }

  }
}
